package com.demo.consumer;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

/**
 * 处理消息的MessageListener
 * Created by HYZ on 2018/1/27.
 *
 * 最原始的消息监听器,JMS规范中定义的接口
 */
public class ConsumerMessageListener implements MessageListener{

    private Logger logger = LoggerFactory.getLogger(ConsumerMessageListener.class);

    @Override
    public void onMessage(Message message) {
        TextMessage textMessage = (TextMessage) message;
        logger.info("接收到一个纯文本消息");
        try {
            logger.info("接收到的消息是:{}",textMessage.getText());
        } catch (JMSException e) {
            logger.error("",e);
        }
    }

}
